package com.llkj.qingnianguoxue.login;

import android.content.Intent;
import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.llkj.qingnianguoxue.MainActivity;
import com.llkj.qingnianguoxue.R;
import com.llkj.qingnianguoxue.base.BaseActivity;
import com.llkj.qingnianguoxue.base.ConstantUserInfo;
import com.llkj.qingnianguoxue.base.MyApplication;
import com.llkj.qingnianguoxue.util.ImageLoadingUtil;

/**
 * 启动页
 */
public class WelcomeActivity extends BaseActivity {
    private LinearLayout ll_welcome;
    private ImageView iv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
//        systemBarTintManager.setStatusBarTintResource(R.color.transparent);
        initStatusbar(TSATUSBAR_TYPE_BLACK_TEXT,null,R.color.transparent);

        init();
        setLoadResourse();
    }

    private void init() {
        ll_welcome = (LinearLayout) findViewById(R.id.ll_welcome);
        iv = (ImageView) findViewById(R.id.iv_start);
    }

    private void setLoadAnimation(){
        AlphaAnimation alphaAnimation = new AlphaAnimation(0.5f, 1.0f);
        alphaAnimation.setDuration(3000);
        ll_welcome.startAnimation(alphaAnimation);
        ll_welcome.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = null;
                boolean isLogin = MyApplication.getInstance().sputil.getBoolean(ConstantUserInfo.ISLOGIN);
                intent = new Intent(WelcomeActivity.this,
                        MainActivity.class);

                startActivity(intent);
                WelcomeActivity.this.finish();
            }
        }, 3000);
    }
    private void setLoadResourse(){
        ImageLoadingUtil.loadLocalImg(iv, R.drawable.start_page);
        setLoadAnimation();
    }
}
